#! /usr/bin/env python3
# -*- coding:utf-8 -*-

'枚举类'
from enum import Enum, unique


Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
                       'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))
for name, member in Month.__members__.items():
    print("月%s %s" % (name, member.value))


@unique
class Week(Enum):
    Sun = 0
    Mon = 1
    Tue = 2
    Wed = 3
    Thu = 4
    Fri = 5
    Sat = 6


for name, member in Week.__members__.items():
    print("周%s %s" % (name, member.value))


# 动态创建类
def printClass(self):
    print("动态类函数：name = %s , age = %d" % (self.name, self.age))


def initAct(self, name, age):
    self.name = name
    self.age = age


ActClass = type("ActClass", (object,),
                dict(name="默认", age=20, printClass=printClass,
                     __init__=initAct))

act = ActClass("test", 21)
act.printClass()
